<?php

namespace App\Task\Recommend;

use App\Amqp\Producer\FemalePushGiftProducer;
use App\Constants\FemaleKeepPushCode;
use App\Model\UserProfile;
use Hyperf\Amqp\Producer;
use Hyperf\Utils\ApplicationContext;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Hyperf\Crontab\Annotation\Crontab;

/**
 * 每天定时修改亲密度
 * @Crontab(name="FemalePushGiftTask", rule="*\/2 * * * *", callback="execute", memo="补充循环数据推入", singleton=false)
 */
class FemalePushGiftTask
{
    /**
     * @return void
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function execute()
    {
        log_info('FemalePushGiftTask:info:execute:Time:' . date('Y-m-d H:i:s'));

//        $expDatetime = date('Y-m-d H:i:s', time() - FemaleKeepPushCode::REG_EXP_TIME);
//        $where = [
//            ['gender','=',0],
//            ['created_at', '>', $expDatetime],
//            ['online','=',1]
//        ];
//
//        $pushUserArr = UserProfile::where($where)->pluck('user_id')->toArray();
//        if (empty($pushUserArr)){
//            log_info('FemalePushGiftTask:info:NoUserId:data:' . json_encode($pushUserArr));
//            return;
//        }
//
//        foreach ($pushUserArr as $one){
//            $message = new FemalePushGiftProducer(['user_id' => $one]);
//            $producer = ApplicationContext::getContainer()->get(Producer::class);
//            $producer->produce($message);
//        }
    }
}